#include "threadpool.hpp"
#include <iostream>
#include <unistd.h>
#include"Log.hpp"
using task_t = function<void()>;

void test()
{
    cout << "hello" << endl;
}

int main()
{
    // Log lg;
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);
    // lg.LogMessage(DEBUG,"main.cc",10,"hello %d world %f",1,2.2);

    // Enable_FILE();
    // LOG(DEBUG,"hello %d world %f",1,2.2);
    // LOG(DEBUG,"hello %d world %f",1,2.2);
    // LOG(DEBUG,"hello %d world %f",1,2.2);
    // LOG(DEBUG,"hello %d world %f",1,2.2);
    // LOG(DEBUG,"hello %d world %f",1,2.2);

    // ThreadPool<task_t> *threadpool = new ThreadPool<task_t>;
    // threadpool->Init();
    // threadpool->Start();

    // int cnt=10;
    // while (true)
    // {

    //     threadpool->Enqueue(test);
    //     cnt--;
    //     sleep(1);
    //     if(cnt==0)
    //     {
    //         threadpool->Stop();
    //         break;
    //     }
           
    // }
    // LOG(DEBUG,"threadpool stop!");
    // sleep(5);

    int cnt = 10;
    while(cnt)
    {
        // 不断地向线程池推送任务
        sleep(1);
        ThreadPool<task_t>::GetInstance()->Enqueue(test);
       LOG(INFO, "equeue a task\n");
        sleep(1);
        cnt--;
    }
    ThreadPool<task_t>::GetInstance()->Stop();
    LOG(INFO, "thread pool stop!\n");
    return 0;
}